package com.kfm.demo.loginmodel.service.impl;


import com.kfm.demo.loginmodel.domain.Users;
import com.kfm.demo.loginmodel.mapper.UsersMapper;
import com.kfm.demo.loginmodel.service.UsersService;
import com.kfm.demo.utils.Resp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * (Users)表服务实现类
 *
 * @author makejava
 * @since 2023-11-13 22:14:38
 */
@Service
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    /**
     * 通过账号和密码
     * @param users
     * @return
     */
    public Resp loginByUser(Users users) {
        Users user = usersMapper.selectByUser(users);
        if (user!= null) {
            return Resp.success(user);
        } else {
            return Resp.error("用户名或密码错误");
        }
    }

    /**
     * 通过电话登录
     * @param users
     * @return
     */
    public Resp loginByPhone(Users users) {
        Users user = usersMapper.selectByUser(users);
        if (user!= null) {
            return Resp.success(user);
        } else {
            return Resp.error("用户名或密码错误");
        }
    }

    /**
     * 通过邮箱登录
     * @param users
     * @return
     */
    public Resp loginByEmail(Users users) {
        Users user = usersMapper.selectByUser(users);
        if (user!= null) {
            return Resp.success(user);
        } else {
            return Resp.error("用户名或密码错误");
        }
    }



}

